package com.zero.manage.web.components.entity;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.zero.manage.web.components.base.BaseDataEntity;
import io.gitee.zerowsh.enums.ToolEnums;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "t_database_info")
@Getter
@Setter
@ApiModel("数据库管理")
public class DatabaseInfoEntity extends BaseDataEntity {
    @ApiModelProperty("数据库")
    @Column(name = "databaseType")
    @NotNull(message = "数据库类型必填")
    @Enumerated(EnumType.STRING)
    private ToolEnums.DataBaseTypeEnums databaseType;

    @ApiModelProperty("数据库用户名")
    @NotBlank(message = "数据库用户名必填")
    @Column(name = "username")
    private String username;

    @ApiModelProperty("数据库密码")
    @NotBlank(message = "数据库密码必填")
    @Column(name = "password")
    //解决返回前端不序列化该字段，接收该字段传值
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    @ApiModelProperty("ip和端口")
    @NotBlank(message = "ip和端口必填")
    @Column(name = "ip_port")
    private String ipPort;

    @ApiModelProperty("数据库其他参数（连接数据库时额外配置）")
    @Column(name = "other_params")
    private String otherParams;
}
